#ifndef _FIG_SFX_H_
#define _FIG_SFX_H_

#include "fig_sounds.h"

#include "ui/ui_manager.h"
#include "vfx/sfx.h"


class FIGLifeObj;

class FIGSfx
{
public:

	enum SFX_TYPES
	{
		EXPLODING_TYPE_NORMAL,
		EXPLODING_TYPE_EXPLODEBANG,		// single explode before going into afterexplode
		EXPLODING_TYPE_AFTEREXPLODE,
		EXPLODING_VERYBIG,
		EXPLODING_TYPE_SMALLHIT,
		EXPLODING_TYPE_ROKETHIT,
		EXPLODING_ROKETSMOKE,
		EXPLODING_SPACEROCK,
		EXPLODING_BONESMOKE,
		EXPLODING_PLAYER,

		PICKUP_TRAIL,
		PICKUP_STAR,
		PICKUP_BULEWEAPON,
		PICKUP_GREENWEAPON,
		PICKUP_REDWEAPON,
		PICKUP_ORB,
		PICKUP_TO_UI,

		PLAYER_BOMB,

		BULLET_FIRE,
		BULLET_GUARDIAN,

		TWINKLE1,
		TWINKLE2,
		SPACE_DUST,

        
		// use random below
		CRAFT_PIECES,
		CRAFT_PIECES_TRIANGLE_FRAME,
		CRAFT_PIECES_TRIANGLE_MAIN,	

		

		SFX_COUNT
		
	};

	FIGSfx(FIGSfx::SFX_TYPES Type);
	~FIGSfx();

	void								Render(const math::Vec2& Offset,float Scale);										
	void								RenderDebug(const math::Vec2& Offset,float Scale);
	void								Tick(float dt);


	void								Clear();
	void								Load(const std::string& Name);
	void								ParticleLoad(const std::string& Name,int	TriggerCount);
	bool								IsAlive() const { return m_IsAlive; };
	FIGSfx*								ReSpawn(	const math::Vec2& Pos,													
													float ScaleSize,
													float Rotation,
													FIGSounds::SOUND_NAMES SFXName,
													bool	bIsRegen = false
													);
	FIGSfx::SFX_TYPES					GetType()const { return m_Type; };
	void								FollowMe(const math::Vec2& Pos);
	void								SetPoition(const math::Vec2& Pos);
	void								ToDie();
	void								SetDelay(float Delay) { m_Delay = Delay; };
	void								SetRotation(float R) { m_Rotation = R; };
	bool								GetIsPostRender() const { return m_IsPostRender; };
	void								SetSkipDrawing(bool b) { m_SkipDrawing = b; };
	void								SetOffsetScale(float OffsetScale) { m_OffsetScale = OffsetScale; };
	void								SetIsRenderByOwner(bool b) { m_IsRenderByOwner = b; };
	bool								GetIsRenderByOwner() const { return m_IsRenderByOwner; };
	void								SetIsRenderAtGround(bool b) { m_IsRenderAtGround = false; };
	bool								GetIsRenderAtGround() const { return m_IsRenderAtGround; };
	void								SetOwner(FIGLifeObj* pObj) { m_pOwner = pObj; };
	bool								IsOwner(FIGLifeObj* pObj) const { return (m_pOwner == pObj); };

protected:

	void								MapTypeToName();
	// FOR Craft Peices Only
	void								Randomize();

	bool								m_IsAlive;
	math::Vec2							m_Pos;
	math::Vec2							m_Size;
	ui::UISprite						m_Sprite;
	FIGSfx::SFX_TYPES					m_Type;

	bool								m_bShouldDisappearWithCounter;
	math::Counter						m_DisappearCounter;


	float								m_Rotation;
	float								m_Alpha;
	math::Vec2							m_RandomDir;
	math::Vec2							m_RandomMovePos;
	float								m_RotationSpeed;

	part2d::Part2D*						m_pParticle;
	int									m_TriggerCount;

	bool								m_bShouldRandomRotate;	
	float								m_Scale;
	float								m_OffsetScale;

	float								m_Delay;
	FIGSounds::SOUND_NAMES				m_SoundSFXName;
	bool								m_IsPostRender;
	bool								m_SkipDrawing;
	bool								m_IsTickCreationFinish;
	bool								m_IsToSpawnOnce;
	math::Vec2							m_SpawnSize;
	bool								m_IsRenderByOwner;  
	bool								m_IsRenderAtGround;  // not using since Renderbyowner works better.
	FIGLifeObj*							m_pOwner;

};

#endif	   // _FIG_SFX_H_